package com.tezign.intelligence.mini.dam.aifamilyconsultant.mapper;

import com.tezign.intelligence.mini.dam.aifamilyconsultant.bean.UserSessionCountDTO;
import com.tezign.intelligence.mini.dam.aifamilyconsultant.entity.Session;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.lettuce.core.dynamic.annotation.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 单次会话信息 Mapper 接口
 * </p>
 *
 * @author six
 * @since 2024-11-16
 */
public interface SessionMapper extends BaseMapper<Session> {
	@Select("<script>" +
			"SELECT user_session_id, COUNT(*) as count " +
			"FROM session " +
			"WHERE user_session_id IN " +
			"<foreach collection='ids' item='id' open='(' separator=',' close=')'>" +
			"#{id}" +
			"</foreach>" +
			"<if test='contents != null and contents.size() > 0'>" +
			" AND content NOT IN " +
			"<foreach collection='contents' item='content' open='(' separator=',' close=')'>" +
			"#{content}" +
			"</foreach>" +
			"</if>" +
			" GROUP BY user_session_id" +
			"</script>")
	List<UserSessionCountDTO> getSessionCounts(@Param("ids") List<Long> ids, @Param("contents") List<String> contents);
}
